home *** CD-ROM | disk | FTP | other *** search
/ United Public Domain Gold 2 / United Public Domain Gold 2.iso / utilities / pu017.dms / pu017.adf / Graphics / Example6.c < prev    next >
C/C++ Source or Header  |  1990-01-30  |  6KB  |  171 lines

  1. /* Example6                                                            */
  2. /* This program will open a normal window which is connected to the    */
  3. /* Workbench Screen. We will then draw the little nice arrow we talked */
  4. /* so much about. This time, however, we draw it several times in      */
  5. /* different colours. This shows how PlanePick/PlaneOnOff works.       */
  6.  
  7.  
  8.  
  9. /* If your program is using Intuition you should include intuition.h: */
  10. #include <intuition/intuition.h>
  11.  
  12.  
  13.  
  14. struct IntuitionBase *IntuitionBase;
  15.  
  16.  
  17.  
  18. /* Declare a pointer to a Window structure: */ 
  19. struct Window *my_window;
  20.  
  21. /* Declare and initialize your NewWindow structure: */
  22. struct NewWindow my_new_window=
  23. {
  24.   40,            /* LeftEdge    x position of the window. */
  25.   20,            /* TopEdge     y positio of the window. */
  26.   150,           /* Width       150 pixels wide. */
  27.   80,            /* Height      80 lines high. */
  28.   0,             /* DetailPen   Text should be drawn with colour reg. 0 */
  29.   1,             /* BlockPen    Blocks should be drawn with colour reg. 1 */
  30.   NULL,          /* IDCMPFlags  No IDCMP flags. */
  31.   SMART_REFRESH| /* Flags       Intuition should refresh the window. */
  32.   WINDOWDRAG|    /*             Drag gadget. */
  33.   WINDOWDEPTH|   /*             Depth arrange Gadgets. */
  34.   ACTIVATE,      /*             The window should be Active when opened. */
  35.   NULL,          /* FirstGadget No Custom Gadgets. */
  36.   NULL,          /* CheckMark   Use Intuition's default CheckMark (v). */
  37.   "ARROWS",      /* Title       Title of the window. */
  38.   NULL,          /* Screen      Connected to the Workbench Screen. */
  39.   NULL,          /* BitMap      No Custom BitMap. */
  40.   0,             /* MinWidth    We do not need to care about these */
  41.   0,             /* MinHeight   since we have not supplied the window */
  42.   0,             /* MaxWidth    with a Sizing Gadget. */
  43.   0,             /* MaxHeight */
  44.   WBENCHSCREEN   /* Type        Connected to the Workbench Screen. */
  45. };
  46.  
  47.  
  48.  
  49. /* REMEMBER! Image data MUST be put in chip-memory! */
  50. USHORT chip my_image_data[]=
  51. {
  52.   0x1000, /* BitPlane ZERO */
  53.   0x3800,
  54.   0x7C00,
  55.   0xFE00,
  56.   0x1000,
  57.   0x1000,
  58.   0x1000,
  59.   0x1000
  60. };
  61.  
  62. /* Orange arrow on black background: */
  63. struct Image my_image4=
  64. {
  65.   70, 30,         /* LeftEdge, TopEdge. */
  66.   7,              /* Width, 7 pixels/bitts wide. */
  67.   8,              /* Height, 8 lines high. */
  68.   1,              /* Depth, only one Bitplane. */
  69.   my_image_data,  /* ImageData, pointer to my_image_data. */
  70.   0x0001,         /* PickPlane, bitplane Zero affects. */
  71.   0x0002,         /* PlaneOnOff, Bitplane One will be filled with 1's. */
  72.                   /* [The pixels' colour will be either 0010 (black) or */
  73.                   /* 0011 (orange).] */
  74.   NULL            /* NextImage, last structure in the list. */
  75. };
  76.  
  77. /* Orange arrow on white background: */
  78. struct Image my_image3=
  79. {
  80.   50, 30,         /* LeftEdge, TopEdge. */
  81.   7,              /* Width, 7 pixels/bitts wide. */
  82.   8,              /* Height, 8 lines high. */
  83.   1,              /* Depth, only one Bitplane. */
  84.   my_image_data,  /* ImageData, pointer to my_image_data. */
  85.   0x0002,         /* PickPlane, bitplane One affects. */
  86.   0x0001,         /* PlaneOnOff, Bitplane Zero will be filled with 1's. */
  87.                   /* [The pixels' colour will be either 0001 (white) or */
  88.                   /* 0011 (orange).] */
  89.   &my_image4      /* NextImage, linked to my_image2. */
  90. };
  91.  
  92. /* Black arrow on blue background: */
  93. struct Image my_image2=
  94. {
  95.   30, 30,         /* LeftEdge, TopEdge. */
  96.   7,              /* Width, 7 pixels/bitts wide. */
  97.   8,              /* Height, 8 lines high. */
  98.   1,              /* Depth, only one Bitplane. */
  99.   my_image_data,  /* ImageData, pointer to my_image_data. */
  100.   0x0002,         /* PickPlane, bitplane One affects. */
  101.   0x0000,         /* PlaneOnOff, 0's on all other Bitplanes. */
  102.                   /* [The pixels' colour will be either 0000 (0:blue) or */
  103.                   /* 0010 (2:black).] */
  104.   &my_image3      /* NextImage, linked to my_image3. */
  105. };
  106.  
  107. /* White arrow on blue background: */
  108. struct Image my_image1=
  109. {
  110.   10, 30,         /* LeftEdge, TopEdge. */
  111.   7,              /* Width, 7 pixels/bitts wide. */
  112.   8,              /* Height, 8 lines high. */
  113.   1,              /* Depth, only one Bitplane. */
  114.   my_image_data,  /* ImageData, pointer to my_image_data. */
  115.   0x0001,         /* PickPlane, bitplane Zero affects. */
  116.   0x0000,         /* PlaneOnOff, 0's on all other Bitplanes. */
  117.                   /* [The pixels' colour will be either 0000 (0:blue) or */
  118.                   /* 0001 (1:white).] */
  119.   &my_image2      /* NextImage, linked to my_image2. */
  120. };
  121.  
  122.  
  123.  
  124. main()
  125. {
  126.   /* Open the Intuition Library: */
  127.   IntuitionBase = (struct IntuitionBase *)
  128.     OpenLibrary( "intuition.library", 0 );
  129.   
  130.   if( IntuitionBase == NULL )
  131.     exit(); /* Could NOT open the Intuition Library! */
  132.  
  133.  
  134.  
  135.   /* We will now try to open the window: */
  136.   my_window = (struct Window *) OpenWindow( &my_new_window );
  137.   
  138.   /* Have we opened the window succesfully? */
  139.   if(my_window == NULL)
  140.   {
  141.     /* Could NOT open the Window! */
  142.     
  143.     /* Close the Intuition Library since we have opened it: */
  144.     CloseLibrary( IntuitionBase );
  145.  
  146.     exit();  
  147.   }
  148.  
  149.  
  150.  
  151.   /* Tell Intuition to draw the images: */
  152.   DrawImage( my_window->RPort, &my_image1, 0, 0 );
  153.  
  154.  
  155.  
  156.   /* We have opened the window, and everything seems to be OK. */
  157.   /* Wait for 30 seconds: */
  158.   Delay( 50 * 30);
  159.  
  160.  
  161.  
  162.   /* We should always close the windows we have opened before we leave: */
  163.   CloseWindow( my_window );
  164.  
  165.  
  166.   
  167.   /* Close the Intuition Library since we have opened it: */
  168.   CloseLibrary( IntuitionBase );
  169.   
  170.   /* THE END */
  171. }